import { ApiProperty } from '@nestjs/swagger'
import { Type } from 'class-transformer'
import { IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator'
import { UserType } from '../entities/work-comment.entity'

export class CreateCommentDto {
  @ApiProperty({ description: '作品ID', example: 1 })
  @IsNotEmpty({ message: '作品ID不能为空' })
  @IsInt({ message: '作品ID必须是整数' })
  @Type(() => Number)
  workId: number

  @ApiProperty({ description: '评论内容', example: '这个作品非常棒！' })
  @IsNotEmpty({ message: '评论内容不能为空' })
  @MaxLength(500, { message: '评论内容不能超过500个字符' })
  content: string

  @ApiProperty({ description: '父评论ID', required: false, example: 1 })
  @IsOptional()
  @IsInt({ message: '父评论ID必须是整数' })
  @Type(() => Number)
  parentId?: number

  @ApiProperty({ description: '用户ID', example: 1 })
  @IsNotEmpty({ message: '用户ID不能为空' })
  @IsInt({ message: '用户ID必须是整数' })
  @Type(() => Number)
  userId: number

  @ApiProperty({ description: '用户类型：1-学生，2-教师', enum: UserType, default: UserType.Teacher })
  @IsEnum(UserType, { message: '无效的用户类型' })
  userType: UserType
} 